// SPDX-License-Identifier: GPL-2.0+
/*
 *  Copyright (C) 2008-2009 Samsung Electronics
 *  Minkyu Kang <mk7.kang@samsung.com>
 *  Kyungmin Park <kyungmin.park@samsung.com>
 */

#include <common.h>
#include <init.h>
#include <net.h>
#include <asm/global_data.h>
#include <asm/gpio.h>
#include <asm/io.h>
#include <asm/arch/sromc.h>
#include <netdev.h>
#include <asm/mach-types.h>
#include <asm/arch/sromc.h>

#ifdef CONFIG_DRIVER_DM9000
#include <net.h>
#include <netdev.h>
#endif

DECLARE_GLOBAL_DATA_PTR;

// #ifdef CONFIG_DRIVER_DM9000

// static void dm9000_srom_init(void)
// {
//     unsigned long bw = SMC_BC_TCOS(1) | SMC_BC_TACC(5) | SMC_BC_TCOH(1) | SMC_BC_TAH(4) | SMC_BC_TACP(6);
//     s5p_config_sromc(1, SMC_DATA16_WIDTH(1), bw);
// }

// static void dm9000_pre_init(void)
// {
//     unsigned int val = 0;
//     struct gpio_info *gpio = get_gpio_data();
//     struct s5p_gpio_bank *mp0_1con = (struct s5p_gpio_bank *)(gpio->reg_addr + (S5PC110_GPIO_MP010 << 2));
//     struct s5p_gpio_bank *mp0_4con = (struct s5p_gpio_bank *)(gpio->reg_addr + (S5PC110_GPIO_MP040 << 2));
//     val = readl(mp0_1con);
//     val &= ~(0xff << 24);
//     val |= 0x22 << 24;
//     writel(val, mp0_1con);

//     val = readl(mp0_4con);
//     val &= ~(0xf << 8);
//     val |= 0x2 << 8;
//     writel(val, mp0_4con);
// }

// #endif

int board_init(void)
{
    gd->bd->bi_arch_number = MACH_TYPE_MINI210;
    gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x100;
    gd->bd->bi_sramstart = 0xd0020000;
    gd->bd->bi_sramsize = 0x40000;
    return 0;
}

int dram_init_banksize(void)
{
    gd->bd->bi_dram[0].start = PHYS_SDRAM_0;
    gd->bd->bi_dram[0].size = PHYS_SDRAM_0_SIZE;
    return 0;
}

#ifdef CONFIG_DISPLAY_BOARDINFO
int checkboard(void)
{
    printf("Board:\tMINI210\n");
    return 0;
}
#endif

int board_eth_init(struct bd_info *bis)
{
#ifdef CONFIG_DRIVER_DM9000
    return dm9000_initialize(bis);
#endif
}

int dram_init(void)
{
    gd->ram_size = get_ram_size(PHYS_SDRAM_0, PHYS_SDRAM_0_SIZE);
    return 0;
}

int misc_init_r(void)
{
    printf("%s\n", __func__);
// #ifdef CONFIG_DRIVER_DM9000
//     dm9000_srom_init();
//     dm9000_pre_init();
// #endif
    return 0;
}

u32 get_board_rev(void)
{
    return 0;
}

